<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <!-- 
      理解数据代理
      通过一个对象对 另一个对象中的属性进行操作
     -->
    <div id="root"></div>
    <script type="text/javascript">
      Vue.config.productionTip = false
      let obj1 = { x: 18 }
      let obj2 = { y: 20 }

      Object.defineProperty(obj2, 'x', {
        //通过obj2获取obj1的x属性
        get() {
          return obj1.x
        },
        //通过obj2去修改obj1中的x属性值
        set(value) {
          obj1.x = value
        },
      })
    </script>
  </body>
</html>
